<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: D:/Projects/MiXiM/extsrc/mixim/src/base/phyLayer/Interpolation.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00293.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">Interpolation.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef INTERPOLATION_H_</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define INTERPOLATION_H_</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &lt;limits&gt;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include &lt;map&gt;</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include &lt;algorithm&gt;</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include &lt;assert.h&gt;</span>
<a name="l00008"></a>00008 
<a name="l00028"></a>00028 <span class="keyword">template</span>&lt;<span class="keyword">class</span> V&gt;
<a name="l00029"></a><a class="code" href="a00111.html">00029</a> <span class="keyword">class </span><a class="code" href="a00111.html" title="Represents an interpolated value of any type.">Interpolated</a> {
<a name="l00030"></a>00030 <span class="keyword">protected</span>:
<a name="l00031"></a>00031   <span class="keyword">typedef</span> V                 value_type;
<a name="l00032"></a>00032   <span class="keyword">typedef</span> <span class="keyword">const</span> value_type&amp; value_cref_type;
<a name="l00033"></a>00033   <span class="keyword">typedef</span> value_type&amp;       value_ref_type;
<a name="l00034"></a>00034   <span class="keyword">typedef</span> value_type*       value_ptr_type;
<a name="l00035"></a>00035 
<a name="l00037"></a><a class="code" href="a00111.html#a767a013b8c29f231984ac735b4b59955">00037</a>   value_type <a class="code" href="a00111.html#a767a013b8c29f231984ac735b4b59955" title="A value this class represents.">value</a>;
<a name="l00038"></a>00038 <span class="keyword">public</span>:
<a name="l00040"></a><a class="code" href="a00111.html#a6b2dcc90823cd33ba7e61f68521bc8c0">00040</a>   <span class="keyword">const</span> <span class="keywordtype">bool</span> <a class="code" href="a00111.html#a6b2dcc90823cd33ba7e61f68521bc8c0" title="Stores if the underlying value is interpolated or not.">isInterpolated</a>;
<a name="l00041"></a>00041 
<a name="l00042"></a>00042 <span class="keyword">public</span>:
<a name="l00043"></a>00043   <a class="code" href="a00111.html" title="Represents an interpolated value of any type.">Interpolated</a>(value_cref_type v, <span class="keywordtype">bool</span> isIntpl = <span class="keyword">true</span>):
<a name="l00044"></a>00044     <a class="code" href="a00111.html#a767a013b8c29f231984ac735b4b59955" title="A value this class represents.">value</a>(v), <a class="code" href="a00111.html#a6b2dcc90823cd33ba7e61f68521bc8c0" title="Stores if the underlying value is interpolated or not.">isInterpolated</a>(isIntpl) {}
<a name="l00045"></a>00045 
<a name="l00049"></a><a class="code" href="a00111.html#a5bc92404ea98f1d8c353a378410be2d9">00049</a>   <a class="code" href="a00111.html" title="Represents an interpolated value of any type.">Interpolated</a>(<span class="keyword">const</span> <a class="code" href="a00111.html" title="Represents an interpolated value of any type.">Interpolated&lt;value_type&gt;</a>&amp; o):
<a name="l00050"></a>00050     <a class="code" href="a00111.html#a767a013b8c29f231984ac735b4b59955" title="A value this class represents.">value</a>(o.<a class="code" href="a00111.html#a767a013b8c29f231984ac735b4b59955" title="A value this class represents.">value</a>), <a class="code" href="a00111.html#a6b2dcc90823cd33ba7e61f68521bc8c0" title="Stores if the underlying value is interpolated or not.">isInterpolated</a>(o.<a class="code" href="a00111.html#a6b2dcc90823cd33ba7e61f68521bc8c0" title="Stores if the underlying value is interpolated or not.">isInterpolated</a>) {}
<a name="l00051"></a>00051 
<a name="l00052"></a>00052   value_ref_type operator*() {
<a name="l00053"></a>00053     <span class="keywordflow">return</span> <a class="code" href="a00111.html#a767a013b8c29f231984ac735b4b59955" title="A value this class represents.">value</a>;
<a name="l00054"></a>00054   }
<a name="l00055"></a>00055 
<a name="l00056"></a>00056   value_ptr_type operator-&gt;() {
<a name="l00057"></a>00057     <span class="keywordflow">return</span> &amp;<a class="code" href="a00111.html#a767a013b8c29f231984ac735b4b59955" title="A value this class represents.">value</a>;
<a name="l00058"></a>00058   }
<a name="l00059"></a>00059 
<a name="l00063"></a><a class="code" href="a00111.html#aa79ee9b9410d2c1477bf8cc296a4a418">00063</a>   <span class="keywordtype">bool</span> <a class="code" href="a00111.html#aa79ee9b9410d2c1477bf8cc296a4a418" title="Two Interpolated&lt;V&gt; are compared equal if the value is the same as well as the &quot;isInterpolated&quot; flag...">operator==</a>(<span class="keyword">const</span> <a class="code" href="a00111.html" title="Represents an interpolated value of any type.">Interpolated&lt;value_type&gt;</a>&amp; other)<span class="keyword"> const </span>{
<a name="l00064"></a>00064     <span class="keywordflow">return</span> <a class="code" href="a00111.html#a767a013b8c29f231984ac735b4b59955" title="A value this class represents.">value</a> == other.<a class="code" href="a00111.html#a767a013b8c29f231984ac735b4b59955" title="A value this class represents.">value</a> &amp;&amp; <a class="code" href="a00111.html#a6b2dcc90823cd33ba7e61f68521bc8c0" title="Stores if the underlying value is interpolated or not.">isInterpolated</a> == other.<a class="code" href="a00111.html#a6b2dcc90823cd33ba7e61f68521bc8c0" title="Stores if the underlying value is interpolated or not.">isInterpolated</a>;
<a name="l00065"></a>00065   }
<a name="l00066"></a>00066 
<a name="l00070"></a><a class="code" href="a00111.html#a50f7e4a2eb744d4cc2248d04d213541c">00070</a>   <span class="keywordtype">bool</span> <a class="code" href="a00111.html#a50f7e4a2eb744d4cc2248d04d213541c" title="Two Interpolated&lt;V&gt; are compared non equal if the value differs or the &quot;isInterpolated&quot; flag...">operator!=</a>(<span class="keyword">const</span> <a class="code" href="a00111.html" title="Represents an interpolated value of any type.">Interpolated&lt;value_type&gt;</a>&amp; other)<span class="keyword"> const </span>{
<a name="l00071"></a>00071     <span class="keywordflow">return</span> <a class="code" href="a00111.html#a767a013b8c29f231984ac735b4b59955" title="A value this class represents.">value</a> != other.<a class="code" href="a00111.html#a767a013b8c29f231984ac735b4b59955" title="A value this class represents.">value</a> || <a class="code" href="a00111.html#a6b2dcc90823cd33ba7e61f68521bc8c0" title="Stores if the underlying value is interpolated or not.">isInterpolated</a> != other.<a class="code" href="a00111.html#a6b2dcc90823cd33ba7e61f68521bc8c0" title="Stores if the underlying value is interpolated or not.">isInterpolated</a>;
<a name="l00072"></a>00072   }
<a name="l00073"></a>00073 
<a name="l00074"></a>00074 <span class="keyword">private</span>:
<a name="l00075"></a>00075   <a class="code" href="a00111.html" title="Represents an interpolated value of any type.">Interpolated</a>():
<a name="l00076"></a>00076     <a class="code" href="a00111.html#a767a013b8c29f231984ac735b4b59955" title="A value this class represents.">value</a>(), <a class="code" href="a00111.html#a6b2dcc90823cd33ba7e61f68521bc8c0" title="Stores if the underlying value is interpolated or not.">isInterpolated</a>(true) {}
<a name="l00077"></a>00077 };
<a name="l00078"></a>00078 
<a name="l00084"></a>00084 <span class="keyword">template</span>&lt;<span class="keyword">class</span> Pair, <span class="keyword">class</span> Key&gt;
<a name="l00085"></a><a class="code" href="a00169.html">00085</a> <span class="keyword">class </span><a class="code" href="a00169.html" title="Compares a the first value of a pair to a value.">PairLess</a> {
<a name="l00086"></a>00086 <span class="keyword">public</span>:
<a name="l00087"></a>00087   <span class="keywordtype">bool</span> operator()(<span class="keyword">const</span> Pair&amp; p, <span class="keyword">const</span> Key&amp; v)<span class="keyword"> const </span>{
<a name="l00088"></a>00088     <span class="keywordflow">return</span> p.first &lt; v;
<a name="l00089"></a>00089   }
<a name="l00090"></a>00090 
<a name="l00091"></a>00091   <span class="keywordtype">bool</span> operator()(<span class="keyword">const</span> Key&amp; v, <span class="keyword">const</span> Pair&amp; p)<span class="keyword"> const </span>{
<a name="l00092"></a>00092     <span class="keywordflow">return</span> v &lt; p.first;
<a name="l00093"></a>00093   }
<a name="l00094"></a>00094 
<a name="l00095"></a>00095   <span class="keywordtype">bool</span> operator()(<span class="keyword">const</span> Pair&amp; left, <span class="keyword">const</span> Pair&amp; right)<span class="keyword"> const </span>{
<a name="l00096"></a>00096     <span class="keywordflow">return</span> left.first &lt; right.first;
<a name="l00097"></a>00097   }
<a name="l00098"></a>00098 };
<a name="l00099"></a>00099 
<a name="l00100"></a>00100 <span class="keyword">template</span>&lt;<span class="keyword">class</span> _ContainerType&gt;
<a name="l00101"></a><a class="code" href="a00113.html">00101</a> <span class="keyword">class </span><a class="code" href="a00113.html">InterpolatorBase</a> {
<a name="l00102"></a>00102 <span class="keyword">public</span>:
<a name="l00103"></a>00103   <span class="keyword">typedef</span> _ContainerType                        storage_type;
<a name="l00104"></a>00104   <span class="keyword">typedef</span> storage_type                          container_type;
<a name="l00105"></a>00105   <span class="keyword">typedef</span> <span class="keyword">typename</span> storage_type::key_type       key_type;
<a name="l00106"></a>00106   <span class="keyword">typedef</span> <span class="keyword">const</span> key_type&amp;                       key_cref_type;
<a name="l00107"></a>00107   <span class="keyword">typedef</span> <span class="keyword">typename</span> storage_type::mapped_type    mapped_type;
<a name="l00108"></a>00108   <span class="keyword">typedef</span> <span class="keyword">const</span> mapped_type&amp;                    mapped_cref_type;
<a name="l00109"></a>00109   <span class="keyword">typedef</span> <span class="keyword">typename</span> storage_type::value_type     pair_type;
<a name="l00110"></a>00110   <span class="keyword">typedef</span> <span class="keyword">typename</span> storage_type::iterator       iterator;
<a name="l00111"></a>00111   <span class="keyword">typedef</span> <span class="keyword">typename</span> storage_type::const_iterator const_iterator;
<a name="l00112"></a>00112   <span class="keyword">typedef</span> <a class="code" href="a00169.html">PairLess&lt;pair_type, key_type&gt;</a>         <a class="code" href="a00169.html">comparator_type</a>;
<a name="l00113"></a>00113   <span class="keyword">typedef</span> <a class="code" href="a00111.html">Interpolated&lt;mapped_type&gt;</a>             <a class="code" href="a00111.html">interpolated</a>;
<a name="l00114"></a>00114 
<a name="l00115"></a>00115 <span class="keyword">public</span>:
<a name="l00117"></a><a class="code" href="a00113.html#a833e51f2e6ce34330574ea3850b906db">00117</a>   <a class="code" href="a00169.html">comparator_type</a>    <a class="code" href="a00113.html#a833e51f2e6ce34330574ea3850b906db" title="Comparator for STL functions.">comp</a>;
<a name="l00118"></a>00118 
<a name="l00119"></a>00119 <span class="keyword">protected</span>:
<a name="l00120"></a>00120   <span class="keywordtype">bool</span>               continueOutOfRange;
<a name="l00121"></a>00121   <a class="code" href="a00111.html">interpolated</a>       outOfRangeVal;
<a name="l00122"></a>00122 
<a name="l00123"></a>00123 <span class="keyword">public</span>:
<a name="l00124"></a>00124   <a class="code" href="a00113.html">InterpolatorBase</a>():
<a name="l00125"></a>00125     <a class="code" href="a00113.html#a833e51f2e6ce34330574ea3850b906db" title="Comparator for STL functions.">comp</a>(), continueOutOfRange(true), outOfRangeVal(mapped_type()) {}
<a name="l00126"></a>00126 
<a name="l00127"></a>00127   <a class="code" href="a00113.html">InterpolatorBase</a>(mapped_cref_type oorv):
<a name="l00128"></a>00128     <a class="code" href="a00113.html#a833e51f2e6ce34330574ea3850b906db" title="Comparator for STL functions.">comp</a>(), continueOutOfRange(false), outOfRangeVal(oorv) {}
<a name="l00129"></a>00129 
<a name="l00130"></a>00130   <span class="keyword">virtual</span> ~<a class="code" href="a00113.html">InterpolatorBase</a>() {}
<a name="l00131"></a>00131 
<a name="l00135"></a><a class="code" href="a00113.html#a8cf11628ee68fe8a058021afeb63ac75">00135</a>   <span class="keywordtype">void</span> <a class="code" href="a00113.html#a8cf11628ee68fe8a058021afeb63ac75" title="Getter and Setter method for out of range value.">setOutOfRangeVal</a>(mapped_cref_type oorv) {
<a name="l00136"></a>00136     continueOutOfRange = <span class="keyword">false</span>;
<a name="l00137"></a>00137     outOfRangeVal      = <a class="code" href="a00111.html">interpolated</a>(oorv);
<a name="l00138"></a>00138   }
<a name="l00139"></a>00139   mapped_cref_type getOutOfRangeVal(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{
<a name="l00140"></a>00140     <span class="keywordflow">return</span> *(&amp;outOfRangeVal);
<a name="l00141"></a>00141   }
<a name="l00144"></a>00144   <span class="keywordtype">bool</span> continueAtOutOfRange(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{
<a name="l00145"></a>00145     <span class="keywordflow">return</span> continueOutOfRange;
<a name="l00146"></a>00146   }
<a name="l00147"></a>00147 
<a name="l00159"></a><a class="code" href="a00113.html#af2aaa8a601ff4b04f34578b6e3d9d793">00159</a>   <a class="code" href="a00111.html">interpolated</a> <a class="code" href="a00113.html#af2aaa8a601ff4b04f34578b6e3d9d793" title="Functor operator of this class which interpolates the value at the passed position using the values b...">operator()</a>(<span class="keyword">const</span> const_iterator&amp; first,
<a name="l00160"></a>00160               <span class="keyword">const</span> const_iterator&amp; last,
<a name="l00161"></a>00161               key_cref_type         pos)<span class="keyword"> const </span>{
<a name="l00162"></a>00162 
<a name="l00163"></a>00163     <span class="keywordflow">if</span>(first == last) {
<a name="l00164"></a>00164       <span class="keywordflow">return</span> outOfRangeVal;
<a name="l00165"></a>00165     }
<a name="l00166"></a>00166 
<a name="l00167"></a>00167     const_iterator right = std::upper_bound(first, last, pos, <a class="code" href="a00113.html#a833e51f2e6ce34330574ea3850b906db" title="Comparator for STL functions.">comp</a>);
<a name="l00168"></a>00168 
<a name="l00169"></a>00169     <span class="keywordflow">return</span> <a class="code" href="a00113.html#af2aaa8a601ff4b04f34578b6e3d9d793" title="Functor operator of this class which interpolates the value at the passed position using the values b...">operator()</a>(first, last, pos, right);
<a name="l00170"></a>00170   }
<a name="l00171"></a>00171 
<a name="l00173"></a><a class="code" href="a00113.html#ad595dcb21de2a3342353a6d537a817e7">00173</a>   <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="a00113.html#ad595dcb21de2a3342353a6d537a817e7" title="Represents the interpolator a stepping function.">isStepping</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">false</span>;}
<a name="l00174"></a>00174 
<a name="l00191"></a>00191   <span class="keyword">virtual</span>
<a name="l00192"></a>00192   interpolated <a class="code" href="a00113.html#af2aaa8a601ff4b04f34578b6e3d9d793" title="Functor operator of this class which interpolates the value at the passed position using the values b...">operator()</a>(<span class="keyword">const</span> const_iterator&amp; first,
<a name="l00193"></a>00193               <span class="keyword">const</span> const_iterator&amp; last,
<a name="l00194"></a>00194               key_cref_type         pos,
<a name="l00195"></a>00195               const_iterator        upperBound) <span class="keyword">const</span> = 0;
<a name="l00196"></a>00196 
<a name="l00197"></a>00197 <span class="keyword">protected</span>:
<a name="l00198"></a>00198   interpolated asInterpolated(mapped_cref_type rVal, <span class="keywordtype">bool</span> bIsOutOfRange, <span class="keywordtype">bool</span> bIsInterpolated = <span class="keyword">true</span>)<span class="keyword"> const </span>{
<a name="l00199"></a>00199     <span class="keywordflow">if</span> (!bIsOutOfRange)
<a name="l00200"></a>00200       <span class="keywordflow">return</span> interpolated(rVal, bIsInterpolated);
<a name="l00201"></a>00201 
<a name="l00202"></a>00202     <span class="keywordflow">if</span>(continueOutOfRange)
<a name="l00203"></a>00203       <span class="keywordflow">return</span> interpolated(rVal);
<a name="l00204"></a>00204     <span class="keywordflow">else</span>
<a name="l00205"></a>00205       <span class="keywordflow">return</span> outOfRangeVal;
<a name="l00206"></a>00206   }
<a name="l00207"></a>00207 };
<a name="l00219"></a>00219 <span class="keyword">template</span>&lt;<span class="keyword">class</span> _ContainerType&gt;
<a name="l00220"></a><a class="code" href="a00158.html">00220</a> <span class="keyword">class </span><a class="code" href="a00158.html" title="Given two iterators defining a range of key-value-pairs this class provides interpolation of values f...">NextSmaller</a> : <span class="keyword">public</span> <a class="code" href="a00113.html">InterpolatorBase</a>&lt;_ContainerType&gt; {
<a name="l00221"></a>00221 <span class="keyword">protected</span>:
<a name="l00222"></a>00222   <span class="keyword">typedef</span> <a class="code" href="a00113.html">InterpolatorBase&lt;_ContainerType&gt;</a> <a class="code" href="a00113.html">base_class_type</a>;
<a name="l00223"></a>00223 
<a name="l00224"></a>00224 <span class="keyword">public</span>:
<a name="l00225"></a>00225   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::storage_type     storage_type;
<a name="l00226"></a>00226   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::container_type   container_type;
<a name="l00227"></a>00227   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::key_type         key_type;
<a name="l00228"></a>00228   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::key_cref_type    key_cref_type;
<a name="l00229"></a>00229   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::mapped_type      mapped_type;
<a name="l00230"></a>00230   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::mapped_cref_type mapped_cref_type;
<a name="l00231"></a>00231   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::pair_type        pair_type;
<a name="l00232"></a>00232   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::iterator         iterator;
<a name="l00233"></a>00233   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::const_iterator   const_iterator;
<a name="l00234"></a>00234   <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="a00169.html">base_class_type::comparator_type</a>  <a class="code" href="a00169.html">comparator_type</a>;
<a name="l00235"></a>00235   <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="a00111.html">base_class_type::interpolated</a>     <a class="code" href="a00111.html">interpolated</a>;
<a name="l00236"></a>00236 
<a name="l00237"></a>00237 <span class="keyword">public</span>:
<a name="l00238"></a>00238   <a class="code" href="a00158.html" title="Given two iterators defining a range of key-value-pairs this class provides interpolation of values f...">NextSmaller</a>():
<a name="l00239"></a>00239     <a class="code" href="a00113.html">base_class_type</a>() {}
<a name="l00240"></a>00240 
<a name="l00241"></a>00241   <a class="code" href="a00158.html" title="Given two iterators defining a range of key-value-pairs this class provides interpolation of values f...">NextSmaller</a>(mapped_cref_type oorv):
<a name="l00242"></a>00242     <a class="code" href="a00113.html">base_class_type</a>(oorv) {}
<a name="l00243"></a>00243 
<a name="l00244"></a>00244   <span class="keyword">virtual</span> ~<a class="code" href="a00158.html" title="Given two iterators defining a range of key-value-pairs this class provides interpolation of values f...">NextSmaller</a>() {}
<a name="l00245"></a>00245 
<a name="l00262"></a>00262   <span class="keyword">virtual</span>
<a name="l00263"></a><a class="code" href="a00158.html#a3dae081c993095eaedbdb40af0b3a749">00263</a>   <a class="code" href="a00111.html">interpolated</a> <a class="code" href="a00158.html#a3dae081c993095eaedbdb40af0b3a749" title="Functor operator of this class which interpolates the value at the passed position using the values b...">operator()</a>(<span class="keyword">const</span> const_iterator&amp; first,
<a name="l00264"></a>00264               <span class="keyword">const</span> const_iterator&amp; last,
<a name="l00265"></a>00265               key_cref_type         pos,
<a name="l00266"></a>00266               const_iterator        upperBound)<span class="keyword"> const </span>{
<a name="l00267"></a>00267     <span class="keywordflow">if</span>(first == last) {
<a name="l00268"></a>00268       <span class="keywordflow">return</span> base_class_type::outOfRangeVal;
<a name="l00269"></a>00269     }
<a name="l00270"></a>00270     <span class="keywordflow">if</span>(upperBound == first) {
<a name="l00271"></a>00271       <span class="keywordflow">return</span> this-&gt;asInterpolated(upperBound-&gt;second, <span class="keyword">true</span>);
<a name="l00272"></a>00272     }
<a name="l00273"></a>00273 
<a name="l00274"></a>00274     upperBound--;
<a name="l00275"></a>00275     <span class="keywordflow">return</span> this-&gt;asInterpolated(upperBound-&gt;second, <span class="keyword">false</span>, !(upperBound-&gt;first == pos));
<a name="l00276"></a>00276   }
<a name="l00277"></a>00277 
<a name="l00279"></a><a class="code" href="a00158.html#ac240448bfa4fd4a033d5d393a5332e38">00279</a>   <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="a00158.html#ac240448bfa4fd4a033d5d393a5332e38" title="Represents the interpolator a stepping function.">isStepping</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">true</span>;}
<a name="l00280"></a>00280 };
<a name="l00281"></a>00281 
<a name="l00290"></a>00290 <span class="keyword">template</span>&lt;<span class="keyword">class</span> _ContainerType&gt;
<a name="l00291"></a><a class="code" href="a00153.html">00291</a> <span class="keyword">class </span><a class="code" href="a00153.html" title="Given two iterators defining a range of key-value-pairs this class provides interpolation of values f...">Nearest</a> : <span class="keyword">public</span> <a class="code" href="a00113.html">InterpolatorBase</a>&lt;_ContainerType&gt; {
<a name="l00292"></a>00292 <span class="keyword">protected</span>:
<a name="l00293"></a>00293   <span class="keyword">typedef</span> <a class="code" href="a00113.html">InterpolatorBase&lt;_ContainerType&gt;</a> <a class="code" href="a00113.html">base_class_type</a>;
<a name="l00294"></a>00294 
<a name="l00295"></a>00295 <span class="keyword">public</span>:
<a name="l00296"></a>00296   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::storage_type     storage_type;
<a name="l00297"></a>00297   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::container_type   container_type;
<a name="l00298"></a>00298   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::key_type         key_type;
<a name="l00299"></a>00299   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::key_cref_type    key_cref_type;
<a name="l00300"></a>00300   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::mapped_type      mapped_type;
<a name="l00301"></a>00301   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::mapped_cref_type mapped_cref_type;
<a name="l00302"></a>00302   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::pair_type        pair_type;
<a name="l00303"></a>00303   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::iterator         iterator;
<a name="l00304"></a>00304   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::const_iterator   const_iterator;
<a name="l00305"></a>00305   <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="a00169.html">base_class_type::comparator_type</a>  <a class="code" href="a00169.html">comparator_type</a>;
<a name="l00306"></a>00306   <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="a00111.html">base_class_type::interpolated</a>     <a class="code" href="a00111.html">interpolated</a>;
<a name="l00307"></a>00307 
<a name="l00308"></a>00308 <span class="keyword">public</span>:
<a name="l00309"></a>00309   <a class="code" href="a00153.html" title="Given two iterators defining a range of key-value-pairs this class provides interpolation of values f...">Nearest</a>():
<a name="l00310"></a>00310     <a class="code" href="a00113.html">base_class_type</a>() {}
<a name="l00311"></a>00311 
<a name="l00312"></a>00312   <a class="code" href="a00153.html" title="Given two iterators defining a range of key-value-pairs this class provides interpolation of values f...">Nearest</a>(mapped_cref_type oorv):
<a name="l00313"></a>00313     <a class="code" href="a00113.html">base_class_type</a>(oorv) {}
<a name="l00314"></a>00314 
<a name="l00315"></a>00315   <span class="keyword">virtual</span> ~<a class="code" href="a00153.html" title="Given two iterators defining a range of key-value-pairs this class provides interpolation of values f...">Nearest</a>() {}
<a name="l00316"></a>00316 
<a name="l00333"></a>00333   <span class="keyword">virtual</span>
<a name="l00334"></a><a class="code" href="a00153.html#a97a548579fe73c473c843a883629efa6">00334</a>   <a class="code" href="a00111.html">interpolated</a> <a class="code" href="a00153.html#a97a548579fe73c473c843a883629efa6" title="Functor operator of this class which interpolates the value at the passed position using the values b...">operator()</a>(<span class="keyword">const</span> const_iterator&amp; first,
<a name="l00335"></a>00335               <span class="keyword">const</span> const_iterator&amp; last,
<a name="l00336"></a>00336               key_cref_type         pos,
<a name="l00337"></a>00337               const_iterator        upperBound)<span class="keyword"> const </span>{
<a name="l00338"></a>00338     <span class="keywordflow">if</span>(first == last) {
<a name="l00339"></a>00339       <span class="keywordflow">return</span> base_class_type::outOfRangeVal;
<a name="l00340"></a>00340     }
<a name="l00341"></a>00341     <span class="keywordflow">if</span>(upperBound == first){
<a name="l00342"></a>00342       <span class="keywordflow">return</span> this-&gt;asInterpolated(upperBound-&gt;second, <span class="keyword">true</span>);
<a name="l00343"></a>00343     }
<a name="l00344"></a>00344 
<a name="l00345"></a>00345     const_iterator left = upperBound;
<a name="l00346"></a>00346     --left;
<a name="l00347"></a>00347 
<a name="l00348"></a>00348     <span class="keywordflow">if</span>(left-&gt;first == pos)
<a name="l00349"></a>00349       <span class="keywordflow">return</span> this-&gt;asInterpolated(left-&gt;second, <span class="keyword">false</span>, <span class="keyword">false</span>);
<a name="l00350"></a>00350 
<a name="l00351"></a>00351     const_iterator right = upperBound;
<a name="l00352"></a>00352 
<a name="l00353"></a>00353     <span class="keywordflow">if</span>(right == last) {
<a name="l00354"></a>00354       <span class="keywordflow">return</span> this-&gt;asInterpolated(left-&gt;second, <span class="keyword">true</span>);
<a name="l00355"></a>00355     }
<a name="l00356"></a>00356 
<a name="l00357"></a>00357     <span class="keywordflow">return</span> this-&gt;asInterpolated( ((pos - left-&gt;first &lt; right-&gt;first - pos) ? left : right)-&gt;second, <span class="keyword">false</span>);
<a name="l00358"></a>00358   }
<a name="l00359"></a>00359 };
<a name="l00360"></a>00360 
<a name="l00361"></a>00361 <span class="keyword">template</span>&lt;<span class="keyword">class</span> TFrom, <span class="keyword">class</span> TTo&gt;
<a name="l00362"></a>00362 TTo cast_it(TFrom rValToCast) {
<a name="l00363"></a>00363   <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span>TTo<span class="keyword">&gt;</span>(rValToCast);
<a name="l00364"></a>00364 }
<a name="l00365"></a>00365 
<a name="l00366"></a>00366 <span class="keyword">template</span>&lt;<span class="keyword">class</span> T&gt;
<a name="l00367"></a>00367 T cast_it(T rValToCast) {
<a name="l00368"></a>00368   <span class="keywordflow">return</span> rValToCast;
<a name="l00369"></a>00369 }
<a name="l00370"></a>00370 
<a name="l00371"></a>00371 <span class="keyword">template</span>&lt;<span class="keyword">class</span> T&gt;
<a name="l00372"></a>00372 T cast_it(simtime_t rValToCast) {
<a name="l00373"></a>00373   <span class="keywordflow">return</span> cast_it(SIMTIME_DBL(rValToCast));
<a name="l00374"></a>00374 }
<a name="l00375"></a>00375 
<a name="l00383"></a>00383 <span class="keyword">template</span>&lt;<span class="keyword">class</span> _ContainerType&gt;
<a name="l00384"></a><a class="code" href="a00118.html">00384</a> <span class="keyword">class </span><a class="code" href="a00118.html" title="Given two iterators defining a range of key-value-pairs this class provides linear interpolation of t...">Linear</a> : <span class="keyword">public</span> <a class="code" href="a00113.html">InterpolatorBase</a>&lt;_ContainerType&gt;  {
<a name="l00385"></a>00385 <span class="keyword">protected</span>:
<a name="l00386"></a>00386   <span class="keyword">typedef</span> <a class="code" href="a00113.html">InterpolatorBase&lt;_ContainerType&gt;</a> <a class="code" href="a00113.html">base_class_type</a>;
<a name="l00387"></a>00387 
<a name="l00388"></a>00388 <span class="keyword">public</span>:
<a name="l00389"></a>00389   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::storage_type     storage_type;
<a name="l00390"></a>00390   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::container_type   container_type;
<a name="l00391"></a>00391   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::key_type         key_type;
<a name="l00392"></a>00392   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::key_cref_type    key_cref_type;
<a name="l00393"></a>00393   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::mapped_type      mapped_type;
<a name="l00394"></a>00394   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::mapped_cref_type mapped_cref_type;
<a name="l00395"></a>00395   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::pair_type        pair_type;
<a name="l00396"></a>00396   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::iterator         iterator;
<a name="l00397"></a>00397   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::const_iterator   const_iterator;
<a name="l00398"></a>00398   <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="a00169.html">base_class_type::comparator_type</a>  <a class="code" href="a00169.html">comparator_type</a>;
<a name="l00399"></a>00399   <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="a00111.html">base_class_type::interpolated</a>     <a class="code" href="a00111.html">interpolated</a>;
<a name="l00400"></a>00400 
<a name="l00401"></a>00401 <span class="keyword">public</span>:
<a name="l00402"></a>00402   <a class="code" href="a00118.html" title="Given two iterators defining a range of key-value-pairs this class provides linear interpolation of t...">Linear</a>():
<a name="l00403"></a>00403     <a class="code" href="a00113.html">base_class_type</a>() {}
<a name="l00404"></a>00404 
<a name="l00405"></a>00405   <a class="code" href="a00118.html" title="Given two iterators defining a range of key-value-pairs this class provides linear interpolation of t...">Linear</a>(mapped_cref_type oorv):
<a name="l00406"></a>00406     <a class="code" href="a00113.html">base_class_type</a>(oorv) {}
<a name="l00407"></a>00407 
<a name="l00408"></a>00408   <span class="keyword">virtual</span> ~<a class="code" href="a00118.html" title="Given two iterators defining a range of key-value-pairs this class provides linear interpolation of t...">Linear</a>() {}
<a name="l00409"></a>00409 
<a name="l00424"></a>00424   <span class="keyword">virtual</span>
<a name="l00425"></a><a class="code" href="a00118.html#a1927a59614f2880683c9ee3795ab59fd">00425</a>   <a class="code" href="a00111.html">interpolated</a> <a class="code" href="a00118.html#a1927a59614f2880683c9ee3795ab59fd" title="Functor operator of this class which linear interpolates the value at the passed position using the v...">operator()</a>(<span class="keyword">const</span> const_iterator&amp; first,
<a name="l00426"></a>00426                           <span class="keyword">const</span> const_iterator&amp; last,
<a name="l00427"></a>00427                           key_cref_type         pos,
<a name="l00428"></a>00428                           const_iterator        upperBound)<span class="keyword"> const </span>{
<a name="l00429"></a>00429     <span class="keywordflow">if</span>(first == last) {
<a name="l00430"></a>00430       <span class="keywordflow">return</span> base_class_type::outOfRangeVal;
<a name="l00431"></a>00431     }
<a name="l00432"></a>00432     <span class="keywordflow">if</span>(upperBound == first){
<a name="l00433"></a>00433       <span class="keywordflow">return</span> this-&gt;asInterpolated(upperBound-&gt;second, <span class="keyword">true</span>);
<a name="l00434"></a>00434     }
<a name="l00435"></a>00435 
<a name="l00436"></a>00436     const_iterator right = upperBound;
<a name="l00437"></a>00437     const_iterator left = --upperBound;
<a name="l00438"></a>00438 
<a name="l00439"></a>00439     <span class="keywordflow">if</span>(left-&gt;first == pos)
<a name="l00440"></a>00440       <span class="keywordflow">return</span> this-&gt;asInterpolated(left-&gt;second, <span class="keyword">false</span>, <span class="keyword">false</span>);
<a name="l00441"></a>00441 
<a name="l00442"></a>00442     <span class="keywordflow">if</span>(right == last){
<a name="l00443"></a>00443       <span class="keywordflow">return</span> this-&gt;asInterpolated(left-&gt;second, <span class="keyword">true</span>);
<a name="l00444"></a>00444     }
<a name="l00445"></a>00445 
<a name="l00446"></a>00446     <span class="keywordflow">return</span> <a class="code" href="a00111.html">interpolated</a>(linearInterpolation(pos, left-&gt;first, right-&gt;first, left-&gt;second, right-&gt;second));
<a name="l00447"></a>00447   }
<a name="l00448"></a>00448 
<a name="l00449"></a>00449 <span class="keyword">protected</span>:
<a name="l00453"></a><a class="code" href="a00118.html#a6bc0698641121198130b488f54692c3f">00453</a>   <span class="keyword">static</span> mapped_type <a class="code" href="a00118.html#a6bc0698641121198130b488f54692c3f" title="Calculates the linear interpolation factor used for the interpolation.">linearInterpolationFactor</a>(key_cref_type t, key_cref_type t0, key_cref_type t1){
<a name="l00454"></a>00454     assert( (t0 &lt;= t &amp;&amp; t &lt;= t1) || (t0 &gt;= t &amp;&amp; t &gt;= t1) );
<a name="l00455"></a>00455     <span class="keywordflow">if</span> (t0 == t1) {
<a name="l00456"></a>00456       <span class="keywordflow">return</span> 0;
<a name="l00457"></a>00457     }
<a name="l00458"></a>00458     <span class="keywordflow">return</span> cast_it&lt;mapped_type&gt;( (t - t0) / (t1 - t0) );
<a name="l00459"></a>00459   }
<a name="l00460"></a>00460 
<a name="l00461"></a>00461   <span class="keyword">static</span> mapped_type linearInterpolation(key_cref_type   t,
<a name="l00462"></a>00462                                         key_cref_type    t0, key_cref_type    t1,
<a name="l00463"></a>00463                                         mapped_cref_type v0, mapped_cref_type v1) {
<a name="l00464"></a>00464     <span class="keyword">typedef</span> std::numeric_limits&lt;mapped_type&gt; tnumlimits_for_v;
<a name="l00465"></a>00465 
<a name="l00466"></a>00466     <span class="keywordflow">if</span> (tnumlimits_for_v::has_infinity) {
<a name="l00467"></a>00467       <span class="comment">// we have possible infinity values, so that we can do some checks</span>
<a name="l00468"></a>00468       <span class="keyword">const</span> mapped_type cInf     = tnumlimits_for_v::infinity();
<a name="l00469"></a>00469       <span class="keyword">const</span> <span class="keywordtype">bool</span>        bV0IsInf = (v0 == cInf) || (tnumlimits_for_v::is_signed ? (v0 == -cInf) : <span class="keyword">false</span>);
<a name="l00470"></a>00470 
<a name="l00471"></a>00471       <span class="keywordflow">if</span> ( bV0IsInf || (v1 == cInf) || (tnumlimits_for_v::is_signed ? (v1 == -cInf) : <span class="keyword">false</span>) ) {
<a name="l00472"></a>00472         <span class="keywordflow">if</span> (tnumlimits_for_v::is_signed &amp;&amp; (v1 == -v0)) {
<a name="l00473"></a>00473           <span class="comment">// v0 == +/-Inf and v1 == -/+Inf</span>
<a name="l00474"></a>00474           <span class="keywordflow">if</span> (tnumlimits_for_v::has_quiet_NaN)
<a name="l00475"></a>00475             <span class="keywordflow">return</span> tnumlimits_for_v::quiet_NaN();
<a name="l00476"></a>00476           <span class="comment">// mhhh!? No quiet_NaN available, so we fall back to old</span>
<a name="l00477"></a>00477           <span class="comment">// handling :(</span>
<a name="l00478"></a>00478         }
<a name="l00479"></a>00479         <span class="keywordflow">else</span> {
<a name="l00480"></a>00480           <span class="comment">// the result should be infinity</span>
<a name="l00481"></a>00481           <span class="keywordflow">return</span> bV0IsInf ? v0 : v1;
<a name="l00482"></a>00482         }
<a name="l00483"></a>00483       }
<a name="l00484"></a>00484     }
<a name="l00485"></a>00485     assert( (t0 &lt;= t &amp;&amp; t &lt;= t1) || (t0 &gt;= t &amp;&amp; t &gt;= t1) );
<a name="l00486"></a>00486     <span class="keywordflow">if</span> (t0 == t1) {
<a name="l00487"></a>00487       assert(v0 == v1);
<a name="l00488"></a>00488       <span class="keywordflow">return</span> v0;
<a name="l00489"></a>00489     }
<a name="l00490"></a>00490     <span class="keyword">const</span> mapped_type mu = <a class="code" href="a00118.html#a6bc0698641121198130b488f54692c3f" title="Calculates the linear interpolation factor used for the interpolation.">linearInterpolationFactor</a>(t, t0, t1);
<a name="l00491"></a>00491 
<a name="l00492"></a>00492     <span class="keywordflow">return</span> v0 * (<span class="keyword">static_cast&lt;</span>mapped_type<span class="keyword">&gt;</span>(1) - mu) + v1 * mu;
<a name="l00493"></a>00493     <span class="comment">//return v0 + (((v1 - v0) * (t - t0)) / (t1 - t0));</span>
<a name="l00494"></a>00494   }
<a name="l00495"></a>00495 };
<a name="l00496"></a>00496 
<a name="l00540"></a>00540 <span class="keyword">template</span>&lt; <span class="keyword">typename</span> _Interpolator, <span class="keyword">typename</span> _IteratorType = <span class="keyword">typename</span> _Interpolator::const_iterator &gt;
<a name="l00541"></a><a class="code" href="a00057.html">00541</a> <span class="keyword">class </span><a class="code" href="a00057.html" title="Template for an interpolateable const iterator for any container which maps from a key to a value...">ConstInterpolateableIterator</a> {
<a name="l00542"></a>00542 <span class="keyword">public</span>:
<a name="l00543"></a>00543   <span class="keyword">typedef</span> _Interpolator                                interpolator_type;
<a name="l00544"></a>00544   <span class="keyword">typedef</span> <span class="keyword">typename</span> interpolator_type::container_type   container_type;
<a name="l00545"></a>00545   <span class="keyword">typedef</span> <span class="keyword">typename</span> interpolator_type::key_type         key_type;
<a name="l00546"></a>00546   <span class="keyword">typedef</span> <span class="keyword">typename</span> interpolator_type::key_cref_type    key_cref_type;
<a name="l00547"></a>00547   <span class="keyword">typedef</span> <span class="keyword">typename</span> interpolator_type::mapped_type      mapped_type;
<a name="l00548"></a>00548   <span class="keyword">typedef</span> <span class="keyword">typename</span> interpolator_type::mapped_cref_type mapped_cref_type;
<a name="l00549"></a>00549   <span class="keyword">typedef</span> <span class="keyword">typename</span> interpolator_type::pair_type        pair_type;
<a name="l00550"></a>00550   <span class="keyword">typedef</span> <span class="keyword">typename</span> interpolator_type::iterator         iterator;
<a name="l00551"></a>00551   <span class="keyword">typedef</span> <span class="keyword">typename</span> interpolator_type::const_iterator   const_iterator;
<a name="l00552"></a>00552   <span class="keyword">typedef</span> <span class="keyword">typename</span> interpolator_type::comparator_type  comparator_type;
<a name="l00553"></a>00553 
<a name="l00554"></a>00554   <span class="keyword">typedef</span> _IteratorType                                used_iterator;
<a name="l00556"></a>00556   <span class="comment">//typedef Interpolated&lt;V&gt; interpolated;</span>
<a name="l00557"></a><a class="code" href="a00057.html#a5ed1c02edab5e7153ef4d29f26e57216">00557</a>   <span class="keyword">typedef</span> <span class="keyword">typename</span> interpolator_type::interpolated     <a class="code" href="a00057.html#a5ed1c02edab5e7153ef4d29f26e57216" title="typedef for the returned Interpolated value of this class.">interpolated</a>;
<a name="l00558"></a>00558 <span class="keyword">protected</span>:
<a name="l00559"></a>00559   used_iterator             first;
<a name="l00560"></a>00560   used_iterator             last;
<a name="l00561"></a>00561   used_iterator             right;
<a name="l00562"></a>00562 
<a name="l00563"></a>00563   key_type                  position;
<a name="l00564"></a>00564   <span class="keyword">const</span> interpolator_type&amp;  interpolate;
<a name="l00565"></a>00565 <span class="keyword">public</span>:
<a name="l00570"></a><a class="code" href="a00057.html#af7376c0555d5afa5e51e5fef70d32d2b">00570</a>   <a class="code" href="a00057.html#af7376c0555d5afa5e51e5fef70d32d2b" title="Initializes the iterator with the passed Iterators as boundaries.">ConstInterpolateableIterator</a>(<span class="keyword">const</span> used_iterator&amp; first, <span class="keyword">const</span> used_iterator&amp; last, <span class="keyword">const</span> interpolator_type&amp; intpl):
<a name="l00571"></a>00571     first(first), last(last), right(first), position(), interpolate(intpl) {
<a name="l00572"></a>00572 
<a name="l00573"></a>00573     <a class="code" href="a00057.html#a812d4bd2ab7b419deb933b8c472e1912" title="Moves the iterator to the first element.">jumpToBegin</a>();
<a name="l00574"></a>00574   }
<a name="l00575"></a>00575   <span class="keyword">virtual</span> ~<a class="code" href="a00057.html" title="Template for an interpolateable const iterator for any container which maps from a key to a value...">ConstInterpolateableIterator</a>() {}
<a name="l00576"></a>00576 
<a name="l00577"></a>00577   <span class="keywordtype">bool</span> operator==(<span class="keyword">const</span> <a class="code" href="a00057.html" title="Template for an interpolateable const iterator for any container which maps from a key to a value...">ConstInterpolateableIterator</a>&amp; other) {
<a name="l00578"></a>00578     <span class="keywordflow">return</span> position == other.position &amp;&amp; right == other.right;
<a name="l00579"></a>00579   }
<a name="l00580"></a>00580 
<a name="l00585"></a><a class="code" href="a00057.html#ad149b5c37b429ccc1fc5615c217cd3de">00585</a>   <span class="keywordtype">void</span> <a class="code" href="a00057.html#ad149b5c37b429ccc1fc5615c217cd3de" title="Moves the iterator to the passed position. This position can be any value of the Key-type.">jumpTo</a>(key_cref_type pos) {
<a name="l00586"></a>00586     <span class="keywordflow">if</span>(pos == position)
<a name="l00587"></a>00587       <span class="keywordflow">return</span>;
<a name="l00588"></a>00588 
<a name="l00589"></a>00589     <span class="keywordflow">if</span>(first != last)
<a name="l00590"></a>00590       right = std::upper_bound(first, last, pos, interpolate.comp);
<a name="l00591"></a>00591 
<a name="l00592"></a>00592     position = pos;
<a name="l00593"></a>00593   }
<a name="l00594"></a>00594 
<a name="l00598"></a><a class="code" href="a00057.html#a812d4bd2ab7b419deb933b8c472e1912">00598</a>   <span class="keywordtype">void</span> <a class="code" href="a00057.html#a812d4bd2ab7b419deb933b8c472e1912" title="Moves the iterator to the first element.">jumpToBegin</a>() {
<a name="l00599"></a>00599     right = first;
<a name="l00600"></a>00600     <span class="keywordflow">if</span>(right != last) {
<a name="l00601"></a>00601       position = right-&gt;first;
<a name="l00602"></a>00602       ++right;
<a name="l00603"></a>00603     } <span class="keywordflow">else</span> {
<a name="l00604"></a>00604       position = key_type();
<a name="l00605"></a>00605     }
<a name="l00606"></a>00606   }
<a name="l00607"></a>00607 
<a name="l00616"></a><a class="code" href="a00057.html#a0a190c448a5cfbcd3385c6ccd316542f">00616</a>   <span class="keywordtype">void</span> <a class="code" href="a00057.html#a0a190c448a5cfbcd3385c6ccd316542f" title="forward iterates the iterator to the passed position. This position can be any value of the Key-type...">iterateTo</a>(key_cref_type pos) {
<a name="l00617"></a>00617     <span class="keywordflow">if</span>(pos == position)
<a name="l00618"></a>00618       <span class="keywordflow">return</span>;
<a name="l00619"></a>00619 
<a name="l00620"></a>00620     <span class="keywordflow">while</span>(right != last &amp;&amp; !(pos &lt; right-&gt;first))
<a name="l00621"></a>00621       ++right;
<a name="l00622"></a>00622 
<a name="l00623"></a>00623     position = pos;
<a name="l00624"></a>00624   }
<a name="l00625"></a>00625 
<a name="l00634"></a><a class="code" href="a00057.html#aa9b9aaf1491ef6ef251bc7399aecdf52">00634</a>   <span class="keywordtype">void</span> <a class="code" href="a00057.html#aa9b9aaf1491ef6ef251bc7399aecdf52" title="Iterates to the next entry in the underlying data structure.">next</a>() {
<a name="l00635"></a>00635     <span class="keywordflow">if</span>(<a class="code" href="a00057.html#a4906a4e7a03086a28d108fc262faa969" title="Returns true if the a call of &quot;next()&quot; would increase to the position of an a valid entry of the data...">hasNext</a>()) {
<a name="l00636"></a>00636       position = right-&gt;first;
<a name="l00637"></a>00637       ++right;
<a name="l00638"></a>00638     } <span class="keywordflow">else</span>
<a name="l00639"></a>00639       position += 1;
<a name="l00640"></a>00640   }
<a name="l00641"></a>00641 
<a name="l00642"></a>00642   key_type getNextPosition(){
<a name="l00643"></a>00643     <span class="keywordflow">if</span>(<a class="code" href="a00057.html#a4906a4e7a03086a28d108fc262faa969" title="Returns true if the a call of &quot;next()&quot; would increase to the position of an a valid entry of the data...">hasNext</a>())
<a name="l00644"></a>00644       <span class="keywordflow">return</span> right-&gt;first;
<a name="l00645"></a>00645     <span class="keywordflow">else</span>
<a name="l00646"></a>00646       <span class="keywordflow">return</span> position + 1;
<a name="l00647"></a>00647   }
<a name="l00648"></a>00648 
<a name="l00653"></a><a class="code" href="a00057.html#a4eca971338ae67b5ee34503cbcf1f342">00653</a>   <span class="keywordtype">bool</span> <a class="code" href="a00057.html#a4eca971338ae67b5ee34503cbcf1f342" title="Returns true if the current position of the iterator is between the position of the first and the las...">inRange</a>()<span class="keyword"> const</span>{
<a name="l00654"></a>00654     <span class="keywordflow">if</span>(first == last)
<a name="l00655"></a>00655       <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00656"></a>00656 
<a name="l00657"></a>00657     const_iterator tail = last;
<a name="l00658"></a>00658     <span class="keywordflow">return</span> !(position &lt; first-&gt;first) &amp;&amp; !((--tail)-&gt;first &lt; position);
<a name="l00659"></a>00659   }
<a name="l00660"></a>00660 
<a name="l00666"></a><a class="code" href="a00057.html#a4906a4e7a03086a28d108fc262faa969">00666</a>   <span class="keywordtype">bool</span> <a class="code" href="a00057.html#a4906a4e7a03086a28d108fc262faa969" title="Returns true if the a call of &quot;next()&quot; would increase to the position of an a valid entry of the data...">hasNext</a>()<span class="keyword"> const</span>{
<a name="l00667"></a>00667     <span class="keywordflow">return</span> right != last;
<a name="l00668"></a>00668   }
<a name="l00669"></a>00669 
<a name="l00676"></a><a class="code" href="a00057.html#afd052facfd07e1a139a6da76d129917e">00676</a>   <a class="code" href="a00057.html#a5ed1c02edab5e7153ef4d29f26e57216" title="typedef for the returned Interpolated value of this class.">interpolated</a> <a class="code" href="a00057.html#afd052facfd07e1a139a6da76d129917e" title="Returns the interpolated value at the current position of the Iterator.">getValue</a>()<span class="keyword"> const</span>{
<a name="l00677"></a>00677     <span class="keywordflow">return</span> interpolate(first, last, position, right);
<a name="l00678"></a>00678   }
<a name="l00679"></a>00679 
<a name="l00680"></a>00680   <a class="code" href="a00057.html#a5ed1c02edab5e7153ef4d29f26e57216" title="typedef for the returned Interpolated value of this class.">interpolated</a> getNextValue()<span class="keyword"> const</span>{
<a name="l00681"></a>00681     <span class="keywordflow">if</span>(right == last) {
<a name="l00682"></a>00682       <span class="keywordflow">return</span> interpolate(first, last, position + 1, right);
<a name="l00683"></a>00683     } <span class="keywordflow">else</span> {
<a name="l00684"></a>00684       const_iterator tmp = right;
<a name="l00685"></a>00685       <span class="keywordflow">return</span> interpolate(first, last, right-&gt;first, ++tmp);
<a name="l00686"></a>00686     }
<a name="l00687"></a>00687   }
<a name="l00688"></a>00688 
<a name="l00692"></a><a class="code" href="a00057.html#a2d8b162ab907fbc33e47db214f28518a">00692</a>   key_cref_type <a class="code" href="a00057.html#a2d8b162ab907fbc33e47db214f28518a" title="Returns the current position of the iterator.">getPosition</a>()<span class="keyword"> const</span>{
<a name="l00693"></a>00693     <span class="keywordflow">return</span> position;
<a name="l00694"></a>00694   }
<a name="l00695"></a>00695 
<a name="l00696"></a>00696   <span class="keyword">const</span> interpolator_type&amp;  getInterpolator()<span class="keyword"> const </span>{
<a name="l00697"></a>00697     <span class="keywordflow">return</span> interpolate;
<a name="l00698"></a>00698   }
<a name="l00699"></a>00699 };
<a name="l00700"></a>00700 
<a name="l00717"></a>00717 <span class="keyword">template</span>&lt; <span class="keyword">typename</span> TInterpolator &gt;
<a name="l00718"></a><a class="code" href="a00109.html">00718</a> <span class="keyword">class </span><a class="code" href="a00109.html" title="Provides an interpolateable iterator for any Container which maps from keys to values which is able t...">InterpolateableIterator</a> : <span class="keyword">public</span> <a class="code" href="a00057.html" title="Template for an interpolateable const iterator for any container which maps from a key to a value...">ConstInterpolateableIterator</a>&lt;TInterpolator, typename TInterpolator::iterator&gt;
<a name="l00719"></a>00719 {
<a name="l00720"></a>00720 <span class="keyword">protected</span>:
<a name="l00721"></a>00721   <span class="keyword">typedef</span> <a class="code" href="a00057.html" title="Template for an interpolateable const iterator for any container which maps from a key to a value...">ConstInterpolateableIterator&lt;TInterpolator, typename TInterpolator::iterator&gt;</a>
<a name="l00722"></a>00722                                                                   <a class="code" href="a00057.html" title="Template for an interpolateable const iterator for any container which maps from a key to a value...">base_class_type</a>;
<a name="l00723"></a>00723   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::container_type                container_type;
<a name="l00724"></a>00724   <span class="keyword">typedef</span> <span class="keyword">typename</span> container_type::const_iterator                 const_iterator;
<a name="l00725"></a>00725   <span class="keyword">typedef</span> <span class="keyword">typename</span> container_type::iterator                       iterator;
<a name="l00726"></a>00726   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::interpolator_type             interpolator_type;
<a name="l00727"></a>00727   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::key_type                      key_type;
<a name="l00728"></a>00728   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::key_cref_type                 key_cref_type;
<a name="l00729"></a>00729   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::mapped_type                   mapped_type;
<a name="l00730"></a>00730   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::mapped_cref_type              mapped_cref_type;
<a name="l00731"></a>00731   <span class="keyword">typedef</span> <span class="keyword">typename</span> container_type::value_type                     pair_type;
<a name="l00732"></a>00732   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::comparator_type               comparator_type;
<a name="l00733"></a>00733 
<a name="l00735"></a>00735   <span class="comment">//typedef Interpolated&lt;V&gt; interpolated;</span>
<a name="l00736"></a><a class="code" href="a00109.html#a28eb737c6b8db4dba638e6ad8246346b">00736</a>   <span class="keyword">typedef</span> <span class="keyword">typename</span> interpolator_type::interpolated                <a class="code" href="a00109.html#a28eb737c6b8db4dba638e6ad8246346b" title="typedef for the returned Interpolated value of this class.">interpolated</a>;
<a name="l00737"></a>00737 
<a name="l00738"></a>00738   container_type&amp; cont;
<a name="l00739"></a>00739 
<a name="l00740"></a>00740 <span class="keyword">public</span>:
<a name="l00741"></a>00741   <a class="code" href="a00109.html" title="Provides an interpolateable iterator for any Container which maps from keys to values which is able t...">InterpolateableIterator</a>(container_type&amp; cont, <span class="keyword">const</span> interpolator_type&amp; intpl):
<a name="l00742"></a>00742     <a class="code" href="a00057.html" title="Template for an interpolateable const iterator for any container which maps from a key to a value...">base_class_type</a>(cont.begin(), cont.end(), intpl), cont(cont) {}
<a name="l00743"></a>00743 
<a name="l00744"></a>00744   <span class="keyword">virtual</span> ~<a class="code" href="a00109.html" title="Provides an interpolateable iterator for any Container which maps from keys to values which is able t...">InterpolateableIterator</a>() {}
<a name="l00749"></a><a class="code" href="a00109.html#ac9ff6164dadb0782ba712d238fc5fa86">00749</a>   <span class="keywordtype">void</span> <a class="code" href="a00109.html#ac9ff6164dadb0782ba712d238fc5fa86" title=": Changes (and adds if necessary) the value for the entry at the current position of the iterator to ...">setValue</a>(mapped_cref_type value) {
<a name="l00750"></a>00750     <span class="comment">//container is empty or position is smaller first entry</span>
<a name="l00751"></a>00751     <span class="keywordflow">if</span>(this-&gt;right == this-&gt;first) {
<a name="l00752"></a>00752       <span class="comment">//insert new entry before first entry and store new entry as new first</span>
<a name="l00753"></a>00753       this-&gt;first = cont.insert(this-&gt;first, std::make_pair(this-&gt;position, value));
<a name="l00754"></a>00754     } <span class="keywordflow">else</span> {
<a name="l00755"></a>00755       iterator left = this-&gt;right;
<a name="l00756"></a>00756       --left;
<a name="l00757"></a>00757       <span class="keywordflow">if</span>(left-&gt;first == this-&gt;position) {
<a name="l00758"></a>00758         left-&gt;second = value;
<a name="l00759"></a>00759       } <span class="keywordflow">else</span> {
<a name="l00760"></a>00760         cont.insert(this-&gt;right, std::make_pair(this-&gt;position, value));
<a name="l00761"></a>00761       }
<a name="l00762"></a>00762     }
<a name="l00763"></a>00763   }
<a name="l00764"></a>00764 };
<a name="l00765"></a>00765 
<a name="l00777"></a>00777 <span class="keyword">template</span>&lt; <span class="keyword">class</span> TInterpolator, <span class="keyword">class</span> TContainer = <span class="keyword">typename</span> TInterpolator::container_type &gt;
<a name="l00778"></a><a class="code" href="a00110.html">00778</a> <span class="keyword">class </span><a class="code" href="a00110.html" title="Represents a std::map which is able to interpolate.">InterpolateableMap</a> : <span class="keyword">public</span> TContainer {
<a name="l00779"></a>00779 <span class="keyword">public</span>:
<a name="l00780"></a>00780   <span class="keyword">typedef</span> TContainer                                              container_type;
<a name="l00781"></a>00781   <span class="keyword">typedef</span> TInterpolator                                           interpolator_type;
<a name="l00782"></a>00782   <span class="keyword">typedef</span> container_type                                          base_class_type;
<a name="l00783"></a>00783   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::key_type                      key_type;
<a name="l00784"></a>00784   <span class="keyword">typedef</span> <span class="keyword">const</span> key_type&amp;                                         key_cref_type;
<a name="l00785"></a>00785   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::mapped_type                   mapped_type;
<a name="l00786"></a>00786   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::value_type                    pair_type;
<a name="l00787"></a>00787   <span class="keyword">typedef</span> <span class="keyword">const</span> mapped_type&amp;                                      mapped_cref_type;
<a name="l00788"></a>00788 
<a name="l00790"></a>00790   <span class="comment">//typedef Interpolated&lt;V&gt; interpolated;</span>
<a name="l00791"></a><a class="code" href="a00110.html#a4c406f0681ae69646e492c3131786189">00791</a>   <span class="keyword">typedef</span> <span class="keyword">typename</span> interpolator_type::interpolated                <a class="code" href="a00110.html#a4c406f0681ae69646e492c3131786189" title="typedef for the returned Interpolated value of this class.">interpolated</a>;
<a name="l00792"></a>00792   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::const_iterator                const_iterator;
<a name="l00793"></a>00793   <span class="keyword">typedef</span> <span class="keyword">typename</span> base_class_type::iterator                      iterator;
<a name="l00794"></a>00794 
<a name="l00795"></a>00795   <span class="keyword">typedef</span> <a class="code" href="a00109.html" title="Provides an interpolateable iterator for any Container which maps from keys to values which is able t...">InterpolateableIterator&lt;TInterpolator&gt;</a>                  <a class="code" href="a00109.html" title="Provides an interpolateable iterator for any Container which maps from keys to values which is able t...">iterator_intpl</a>;
<a name="l00796"></a>00796   <span class="keyword">typedef</span> <a class="code" href="a00057.html" title="Template for an interpolateable const iterator for any container which maps from a key to a value...">ConstInterpolateableIterator&lt;TInterpolator&gt;</a>             <a class="code" href="a00057.html" title="Template for an interpolateable const iterator for any container which maps from a key to a value...">const_iterator_intpl</a>;
<a name="l00797"></a>00797 
<a name="l00798"></a>00798 <span class="keyword">protected</span>:
<a name="l00799"></a>00799 
<a name="l00800"></a>00800   interpolator_type interpolate;
<a name="l00801"></a>00801 <span class="keyword">public</span>:
<a name="l00802"></a>00802 
<a name="l00803"></a>00803   <a class="code" href="a00110.html" title="Represents a std::map which is able to interpolate.">InterpolateableMap</a>():
<a name="l00804"></a>00804     interpolate() {}
<a name="l00805"></a>00805 
<a name="l00806"></a>00806   <a class="code" href="a00110.html" title="Represents a std::map which is able to interpolate.">InterpolateableMap</a>(mapped_cref_type oorv):
<a name="l00807"></a>00807     interpolate(oorv) {}
<a name="l00808"></a>00808 
<a name="l00809"></a>00809   <span class="keywordtype">void</span> setOutOfRangeVal(mapped_cref_type oorv) {
<a name="l00810"></a>00810     interpolate.setOutOfRangeVal(oorv);
<a name="l00811"></a>00811   }
<a name="l00812"></a>00812 
<a name="l00813"></a>00813   <a class="code" href="a00110.html#a4c406f0681ae69646e492c3131786189" title="typedef for the returned Interpolated value of this class.">interpolated</a> getIntplValue(key_cref_type pos)<span class="keyword"> const </span>{
<a name="l00814"></a>00814     <span class="keywordflow">return</span> interpolate(this-&gt;begin(), this-&gt;end(), pos, this-&gt;upper_bound(pos));
<a name="l00815"></a>00815   }
<a name="l00816"></a>00816 
<a name="l00817"></a>00817   const_iterator_intpl findIntpl(key_cref_type pos)<span class="keyword"> const</span>{
<a name="l00818"></a>00818     const_iterator_intpl it(this-&gt;begin(), this-&gt;end(), interpolate);
<a name="l00819"></a>00819 
<a name="l00820"></a>00820     it.jumpTo(pos);
<a name="l00821"></a>00821 
<a name="l00822"></a>00822     <span class="keywordflow">return</span> it;
<a name="l00823"></a>00823   }
<a name="l00824"></a>00824 
<a name="l00825"></a>00825   const_iterator_intpl beginIntpl()<span class="keyword"> const</span>{
<a name="l00826"></a>00826     const_iterator_intpl it(this-&gt;begin(), this-&gt;end(), interpolate);
<a name="l00827"></a>00827 
<a name="l00828"></a>00828     <span class="keywordflow">return</span> it;
<a name="l00829"></a>00829   }
<a name="l00830"></a>00830 
<a name="l00831"></a>00831   iterator_intpl findIntpl(key_cref_type pos) __attribute__ ((noinline)) {
<a name="l00832"></a>00832     iterator_intpl it(*<span class="keyword">this</span>, interpolate);
<a name="l00833"></a>00833 
<a name="l00834"></a>00834     it.jumpTo(pos);
<a name="l00835"></a>00835 
<a name="l00836"></a>00836     <span class="keywordflow">return</span> it;
<a name="l00837"></a>00837   }
<a name="l00838"></a>00838 
<a name="l00839"></a>00839   iterator_intpl beginIntpl() {
<a name="l00840"></a>00840     iterator_intpl it(*<span class="keyword">this</span>, interpolate);
<a name="l00841"></a>00841 
<a name="l00842"></a>00842     <span class="keywordflow">return</span> it;
<a name="l00843"></a>00843   }
<a name="l00844"></a>00844 };
<a name="l00845"></a>00845 <span class="preprocessor">#endif </span><span class="comment">/*INTERPOLATION_H_*/</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><b>Interpolation.h</b>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:30 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
